<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        var arr = ['齐','楚','燕','韩','赵','魏','秦'] 
        //从前往后获取索引号
        console.log(arr.indexOf('楚'))
        console.log(arr.indexOf('糖'))
        //从后往前获取索引号
        console.log(arr.lastIndexOf('楚'))
        console.log(arr.lastIndexOf('糖'))
    </script>
</body>
</html>